﻿using System;

namespace MaxPrimeNumber
{
    internal class Program
    {/// <summary>
     /// 求最大质数
     /// </summary>
     /// <param name="args"></param>
        static void Main(string[] args)
        { //输入想求最大质数的范围
            int num = Convert.ToInt32(Console.ReadLine());
            int j;
            int i = 2, max = 2;
            //设置时间变量
            double span = 0;
            bool flag = false;
            //遍历所有的数
            for (j = 2; j < num; j++)
            {
                DateTime before = DateTime.Now;
                flag = false;
                for (i = 2; i < (j / 2); i++)
                {
                    if (j % i == 0)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag == false)
                    max = j;
                //求时间
                DateTime after = DateTime.Now;
                span += (after - before).TotalSeconds;
            }
            Console.WriteLine($"最大质数为{max}，所用时间为{span}");
        }
    }
}